﻿@using FCDB.WEB.PagedQuery
@model FCDB.WEB.Models.PagedList<FCDB.Entity.EntityEx.BusinessDeductReportModel>
@{
    ViewBag.Title = "提成汇总";
    Layout = "~/Views/Shared/_POContentLayout.cshtml";
}
@section HeadIncluder
{
    <link rel="stylesheet" type="text/css" href=@Url.Content("~/Scripts/skins/default.css") />
    <link href='@Url.Content("~/Content/public.css")' type="text/css" rel="stylesheet" />
    <link href='@Url.Content("~/Content/con_style.css")' type="text/css" rel="stylesheet" />

}
@{

    FCDB.Entity.EntityEx.BusinessReportModel BusiModel = ViewBag.BusiModel as FCDB.Entity.EntityEx.BusinessReportModel;
    <form id="GetForm" name="GetForm" method="get" action="@Url.Action("BusinessDeductReport", "BusinessReport")">
        <div>
            <table class="tb-search mb10" style="width: 100%;">
                <tr>
                    <td class="box " style="width: 80%;">
                        法院:<input class="input-style-txt form-input" id="Court" name="Court" value="@BusiModel.Court" style="width: 120px" type="text">
                        创建时间:<input id="dtStart" name="dtStart" value="@BusiModel.dtStart.Value.ToString("yyyy-MM-dd")" style="width: 120px" type="text" />至：
                        <input id="dtEnd" name="dtEnd" value="@BusiModel.dtEnd.Value.ToString("yyyy-MM-dd")" style="width: 120px" type="text" />
                        业务员:
                        <input id="txtSalesmanName" class="input-style-txt form-input" type="text" name="SalesmanName"
                               readonly="readonly" value="@BusiModel.SalesmanName" style="width:120px;" />
                        <input type="hidden" id="SalesmanID" name="SalesmanID" value="@BusiModel.SalesmanID" />
                        <input type="button" onclick="addUsers()" value="添加" class="btn btn-blue " />
                       
                    </td>
                </tr>
                <tr>
                    <td class="box " style="width: 90%;">
                        申请人:<input class="input-style-txt form-input" id="Respondent" name="Respondent" value="@BusiModel.Respondent" style="width: 120px" type="text" />
                        部门:
                        <input class="input-style-txt form-input" id="txtDeptName" name="txtDeptName" value="@BusiModel.txtDeptName" readonly="readonly" style="width: 120px" type="text" />
                        <input class="input-style-txt form-input" id="DeptCode" name="DeptCode" value="@BusiModel.DeptCode" type="hidden" />
                        <input type="button" onclick="SelectDeparment(DeptCode, txtDeptName)" value="选择部门" class="btn btn-blue " />
                        收款状态:<select class="form-select" name="ChargeStatus">
                            <option value="0" @(BusiModel.ChargeStatus == 0 ? "selected" : "")>全部</option>
                            <option value="1" @(BusiModel.ChargeStatus == 1 ? "selected" : "")>未收款</option>
                            <option value="2" @(BusiModel.ChargeStatus == 2 ? "selected" : "")>已收款</option>
                        </select>
                        流程状态:<select class="form-select" name="ProcessStatus">
                            <option value="0" @(BusiModel.ProcessStatus == 0 ? "selected" : "")>全部</option>
                            <option value="1" @(BusiModel.ProcessStatus == 1 ? "selected" : "")>流转中</option>
                            <option value="2" @(BusiModel.ProcessStatus == 2 ? "selected" : "")>已结束</option>
                        </select>
                        提成状态:<select class="form-select" name="DebutStatus">
                            <option value="0" @(BusiModel.DebutStatus == 0 ? "selected" : "")>全部</option>
                            <option value="1" @(BusiModel.DebutStatus == 1 ? "selected" : "")>未提成</option>
                            <option value="2" @(BusiModel.DebutStatus == 2 ? "selected" : "")>已提成</option>
                        </select>
                        &nbsp; <input type="submit" id="submit" value="查找" class="btn btn-blue " />
                        &nbsp; <input type="button" id="btnExport" onclick="ExportData()" value="导出" class="btn btn-blue " />
                    </td></tr>
            </table>
        </div>
        <div style="overflow:auto;" id="tbData">
            @{
                String cssTableList = "  max-width: 100%;    width: 100%;    border: 1px solid #ddd;    border-left: 0;    border-radius: 4px;    box-shadow: 0 0 10px rgba(0,0,0, .1);";
                String cssTableListTh = "  height: auto;    font-size: 12px;    padding: 8px 10px;    border-bottom: 0;    text-align: left;   color: #fff;    font-weight: 900;    background: #65AAF8;    border-left: 1px solid #ddd;    white-space:nowrap;     text-transform: uppercase;";
                String cssTableListTd = "padding: 5px 10px;   line-height: 20px;    text-align: left;    border-top: 1px solid #ddd;    border-left: 1px solid #ddd;    white-space:nowrap; ";
                String cssTableListTr = "background: #fff;";
                                <table class="table-list" style="@cssTableList">
                    <thead>
                        <tr style="@cssTableListTr">
                            <th style="@cssTableListTh">序号</th>
                            <th style="@cssTableListTh">部门</th>
                            <th style="@cssTableListTh">业务员</th>
                            <th style="@cssTableListTh">标的金额</th>
                            <th style="@cssTableListTh">合同收费</th>
                            <th style="@cssTableListTh">业务提成</th>
                            <th style="@cssTableListTh">业务数量</th>
                        </tr>
                    </thead>

                    <tbody>
                        @if (Model != null)
                        {
                            int index = 0;
                            foreach (var item in Model)
                            {
                                index = index + 1;
                                <tr style="@cssTableListTr">
                                    <td style="@cssTableListTd">@index</td>
                                    <td style="@cssTableListTd">@item.DeptName</td>
                                    <td style="@cssTableListTd">@item.UserName</td>
                                    <td style="@cssTableListTd">@item.BusiAmount</td>
                                    <td style="@cssTableListTd">@item.ActualReciAmount</td>
                                    <td style="@cssTableListTd">@item.DeductSumAmount</td>
                                    <td style="@cssTableListTd">@item.BusiCount</td>
                                </tr>

                            }
                        }
                    </tbody>

                </table>
            }

        </div>
        <div class="bot_bar fn-clear J_fixeBot">
            @Html.Pager(Model, new FCDB.WEB.PagedQuery.PagerOptions
       {
           PageIndexParameterName = "pageIndex",
           AutoHide = false,
           CurrentPagerItemWrapperFormatString = "<span class=\"page_now\">{0}</span>",
           ShowGoButton = true,
           GoButtonText = "goto",
           NumericPagerItemCount = Model.PageSize,
           ShowPageIndexBox = true,
           GoToPageSectionWrapperFormatString = "{0}",
           ShowMorePagerItems = true,
           NumericPagerItemWrapperFormatString = "<span class=\"item\">{0}</span>",
           CssClass = "pagebar",
           SeparatorHtml = "",
           ShowPageSize = true,
           PageSizeParameterName = "pageSize",
           PageSizeBoxType = FCDB.WEB.PagedQuery.PageSizeBoxType.TextBox
       })
        </div>
    </form>
    <script type="text/javascript" src='@Url.Content("~/Scripts/lhgdialog.min.js")'> </script>


    <script type="text/javascript">
    $(function () {
        $("#dtStart").kendoDatePicker({ format: "yyyy-MM-dd" });
        $("#dtEnd").kendoDatePicker({ format: "yyyy-MM-dd" });
    });
    function ExportData() {
        var FileStr = encodeURI($("#tbData").html());
        var FileName = "业绩汇总";
        var url = '@Url.Action("SaveFile", "BusinessReport")';
        $.post(url, { strContent: FileStr, FileName: FileName }, function () {
            location = url;
        });
    }
    function addUsers() {
        var url = '@Url.Action("EmployeeSelect", "Employee")';
        OpenSelectUserPop(url, RefreshValue);
    }
    function RefreshValue(selectPostList) {
        if (selectPostList != null || selectPostList != undefined) {
            var strNames = "";
            var strUserIDs = "";
            $.each(selectPostList, function (i, val) {
                strNames = val.Name;
                strUserIDs = val.UserID;
                $("#txtSalesmanName").val(strNames);
                $("#SalesmanID").val(strUserIDs);
            });
        }
    }
    function SelectDeparment(valtag, textTag) {
        var url = '@Url.Action("UCDepartmentSelect", "Form")';
        window.top.winObj = window;
        window.top.refresh = function (vals, txts) {
            $(valtag).val(vals);
            $(textTag).val(txts);
        };
        window.top.oDG = $.dialog({
            lock: true,
            background: '#FFF',
            opacity: 0.5,
            id: 'esDialog',
            title: '部门选择',
            titleAlign: 'left',
            content: "url:" + url,
            width: 570,
            height: 300,
            btnBar: false,
            lockScroll: true
        });
    }

    </script>
}